//
// Created by aaa on 2025/7/10.
//

#include<bits/stdc++.h>

using namespace std;
const int N = 5000 + 10;

int n;
int a[N],dp[N];
int ans;

//最长上升子序列
//6
//1 2 4 1 3 4
int main(){
    cin >> n;

    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        dp[i] = 1;
    }

    for(int i = 1;i <= n;i++){
        for(int j = 1;j < i;j++){
            if(a[i] > a[j]) dp[i] = max(dp[i],dp[j] + 1);
            ans = max(ans,dp[i]);
        }
    }

    cout << ans;

//    for(int i = 1;i <= n;i++){
//        cout << dp[i] << " ";
//    }



    return 0;
}